**# Bookmark #1 Setting

*Windows
global root  = "G:/Dropbox/Environmental Injustice/Empirical"
global rawdata = "$root/rawdata"
global workdata = "$root/workdata"
global results = "$root/results"
global outfile = "$root/outfile"

cd "$workdata"


**# Bookmark #2 Panel A Access to Indoor Toilte

*Cardiovascular Disease
use "$outfile/Table S19 Panel A_heartandday.dta",clear

reghdfe heart lowedu5_post_notoilte lowedu5_post lowedu5_notoilte notoilte_post lowedu5 notoilte post ,absorb(i.id i.province#i.year) cluster(i.province i.year)

outreg2 using "$results/Table S19 Panel A.xls",replace ctitle(Cardiovascular Disease) ///
keep(lowedu5_post_notoilte lowedu5_post) ///
addtext(Individual FE, YES, ProvincebyYear FE, YES) ///
bdec(3) tdec(3) rdec(3)

*Inactive Days
reghdfe day lowedu5_post_notoilte lowedu5_post lowedu5_notoilte notoilte_post lowedu5 notoilte post ,absorb(i.id i.province#i.year) cluster(i.province i.year)

outreg2 using "$results/Table S19 Panel A.xls",append ctitle(Inactive Days) ///
keep(lowedu5_post_notoilte lowedu5_post) ///
addtext(Individual FE, YES, ProvincebyYear FE, YES) ///
bdec(3) tdec(3) rdec(3)

*Tumor
use "$outfile/Table S19 Panel A_tumor.dta",clear

reghdfe tumor lowedu5_post_notoilte lowedu5_post lowedu5_notoilte notoilte_post lowedu5 notoilte post ,absorb(i.id i.province#i.year) cluster(i.province i.year)

outreg2 using "$results/Table S19 Panel A.xls",append ctitle(Tumor) ///
keep(lowedu5_post_notoilte lowedu5_post) ///
addtext(Individual FE, YES, ProvincebyYear FE, YES) ///
bdec(3) tdec(3) rdec(3)

*Health Index
use "$outfile/Table S19 Panel A_heartandday.dta",clear
merge 1:1 IDind hhid line age wave using "$outfile/Table S19 Panel A_tumor.dta",gen(m1)
keep if m1==3

swindex heart day tumor,gen(healthindex)

reghdfe healthindex lowedu5_post_notoilte lowedu5_post lowedu5_notoilte notoilte_post lowedu5 notoilte post ,absorb(i.id i.province#i.year) cluster(i.province i.year)

outreg2 using "$results/Table S19 Panel A.xls",append ctitle(Health Index) ///
keep(lowedu5_post_notoilte lowedu5_post) ///
addtext(Individual FE, YES, ProvincebyYear FE, YES) ///
bdec(3) tdec(3) rdec(3)


**# Bookmark #3 Panel B Randomize Access to Tap Water

*Cardiovascular Disease
use "$outfile/Table S19 Panel B_heartandday",clear

reghdfe heart lowedu5_post_notapwater lowedu5_post lowedu5_notapwater notapwater_post lowedu5 notapwater post,absorb(i.id i.province#i.year) cluster(i.province i.year)

outreg2 using "$results/Table S19 Panel B.xls",replace ctitle(Cardiovascular Disease) ///
keep(lowedu5_post_notapwater lowedu5_post) ///
addtext(Individual FE, YES, ProvincebyYear FE, YES) ///
bdec(3) tdec(3) rdec(3)

*Inactive Days
reghdfe day lowedu5_post_notapwater lowedu5_post lowedu5_notapwater notapwater_post lowedu5 notapwater post,absorb(i.id i.province#i.year) cluster(i.province i.year)

outreg2 using "$results/Table S19 Panel B.xls",append ctitle(Inactive Days) ///
keep(lowedu5_post_notapwater lowedu5_post) ///
addtext(Individual FE, YES, ProvincebyYear FE, YES) ///
bdec(3) tdec(3) rdec(3)

*Tumor
use "$outfile/Table S19 Panel B_tumor",clear

reghdfe tumor lowedu5_post_notapwater lowedu5_post lowedu5_notapwater notapwater_post lowedu5 notapwater post,absorb(i.id i.province#i.year) cluster(i.province i.year)

outreg2 using "$results/Table S19 Panel B.xls",append ctitle(Tumor) ///
keep(lowedu5_post_notapwater lowedu5_post) ///
addtext(Individual FE, YES, ProvincebyYear FE, YES) ///
bdec(3) tdec(3) rdec(3)

*Health Index
use "$outfile/Table S19 Panel B_heartandday.dta",clear
merge 1:1 IDind hhid line age wave using "$outfile/Table S19 Panel B_tumor.dta",gen(m1)
keep if m1==3

swindex heart day tumor,gen(healthindex)

reghdfe healthindex lowedu5_post_notapwater lowedu5_post lowedu5_notapwater notapwater_post lowedu5 notapwater post,absorb(i.id i.province#i.year) cluster(i.province i.year)

outreg2 using "$results/Table S19 Panel B.xls",append ctitle(Health Index) ///
keep(lowedu5_post_notapwater lowedu5_post) ///
addtext(Individual FE, YES, ProvincebyYear FE, YES) ///
bdec(3) tdec(3) rdec(3)
	
	

**# Bookmark #4 Panel C Randomize Education Level

*Cardiovascular Disease
use "$outfile/Table S19 Panel C_heartandday",clear

reghdfe heart lowedu5_post_notapwater lowedu5_post lowedu5_notapwater notapwater_post lowedu5 notapwater post,absorb(i.id i.province#i.year) cluster(i.province i.year)

outreg2 using "$results/Table S19 Panel C.xls",replace ctitle(Cardiovascular Disease) ///
keep(lowedu5_post_notapwater lowedu5_post) ///
addtext(Individual FE, YES, ProvincebyYear FE, YES) ///
bdec(3) tdec(3) rdec(3)

*Inactive Days
reghdfe day lowedu5_post_notapwater lowedu5_post lowedu5_notapwater notapwater_post lowedu5 notapwater post,absorb(i.id i.province#i.year) cluster(i.province i.year)

outreg2 using "$results/Table S19 Panel C.xls",append ctitle(Inactive Days) ///
keep(lowedu5_post_notapwater lowedu5_post) ///
addtext(Individual FE, YES, ProvincebyYear FE, YES) ///
bdec(3) tdec(3) rdec(3)

*Tumor
use "$outfile/Table S19 Panel C_tumor",clear

reghdfe tumor lowedu5_post_notapwater lowedu5_post lowedu5_notapwater notapwater_post lowedu5 notapwater post,absorb(i.id i.province#i.year) cluster(i.province i.year)

outreg2 using "$results/Table S19 Panel C.xls",append ctitle(Tumor) ///
keep(lowedu5_post_notapwater lowedu5_post) ///
addtext(Individual FE, YES, ProvincebyYear FE, YES) ///
bdec(3) tdec(3) rdec(3)
	
*Health Index
use "$outfile/Table S19 Panel C_heartandday.dta",clear
merge 1:1 IDind hhid line age wave using "$outfile/Table S19 Panel C_tumor.dta",gen(m1)
keep if m1==3

swindex heart day tumor,gen(healthindex)

reghdfe healthindex lowedu5_post_notapwater lowedu5_post lowedu5_notapwater notapwater_post lowedu5 notapwater post,absorb(i.id i.province#i.year) cluster(i.province i.year)

outreg2 using "$results/Table S19 Panel C.xls",append ctitle(Health Index) ///
keep(lowedu5_post_notapwater lowedu5_post) ///
addtext(Individual FE, YES, ProvincebyYear FE, YES) ///
bdec(3) tdec(3) rdec(3)
